<template>
  <div class="pro-container" @click="handleItemClick">
    <div class="product"><!---->
      <div>
        <div class="discount" v-if="item.discount"><span>{{item.discount}} %</span><br><span>OFF</span></div>
        <div class="poster">
          <img :src="item.mainimage">
        </div>
        <h2>${{ item.price }}</h2>
        <div class="product-res"> {{$t('CommonSaleNumber')}} {{item.sales}}</div>
        <p> {{ item.name}}</p></div>
      <div class="product-footer">
        <div><i class="el-icon-shopping-cart-full"></i><span class="buy-btn"> {{$t('CommonProductBuy')}} </span></div>
        <div><i class="el-icon-star-off"></i></div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { useRouter } from "vue-router";
const router = useRouter()
const props = defineProps({
  item: {
    type: Object,
    default: () => {
      return {}
    }
  }
})
const handleItemClick = () => {
  router.push('/productDetail')
}
</script>
<style scoped>
.pro-container:hover .product {
  border: 1px solid var(--color-main);
  transform: scale(1.1);
}

.product {
  border: 1px solid var(--color-border);
  padding: 0px 8px 8px;
  border-radius: 5px;
  position: relative;
  transition: all 0.5s ease-in-out;
}

.product > div {
  cursor: pointer;
}

.product .discount {
  width: 31px;
  height: 32px;
  background: url("") 100% center / 100% no-repeat;
  position: absolute;
  top: 0px;
  right: 0px;
  text-align: center;
  font-size: 11px;
  color: rgb(255, 255, 255);
  font-weight: 500;
}

.product .product-res {
  font-family: Roboto;
  font-style: normal;
  font-weight: 400;
  font-size: 10px;
  line-height: 12px;
  color: rgb(153, 153, 153);
}

.product .poster {
  overflow: hidden;
}

.product .poster, .product img {
  width: 100%;
  max-width: 165px;
  height: 165px;
}

.product img {
  object-fit: contain;
}

.product h2 {
  font-size: 16px;
  color: var(--color-price);
  margin-bottom: 6px;
  font-weight: 500;
}

.product p {
  font-size: 14px;
  font-weight: 400;
  min-height: 40px;
  line-height: 1.5;
  color: var(--color-title);
  max-width: 138px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin: 6px 0px 15px;
}

.product-footer {
  justify-content: space-between;
}

.product-footer, .product-footer div {
  display: flex;
  align-items: center;
}

.product-footer .el-icon-shopping-cart-full {
  margin-right: 8px;
}

.product-footer .buy-btn {
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.discount {
  width: 31px;
  height: 32px;
  background: url() no-repeat 100%/100%;
  position: absolute;
  top: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: #fff;
  font-weight: 500
}
</style>